/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AlarmSystemMain;

import CommonValue.CommonString;
import CommonValue.NetConfig;
import CommonValue.SystemSign;
import DTO.ControlDTO;
import DTO.PacketDTO;
import SocketBusiness.SlaveObeyBoss;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class AlarmSystemMain {

    private static final String systemName = SystemSign.AlarmSystem;

    public static void main(String[] args) {

        System.out.println(systemName + CommonString.MainProgram);

        PacketDTO _trigger = new PacketDTO(systemName);
        ControlDTO _operationAS = new ControlDTO(SystemSign.AdminCenter, systemName);

        ASListenWS AS_listen_WS = new ASListenWS(systemName, NetConfig.AlaSys_Listen_WeaSys_Port,_operationAS,_trigger);
        Thread t1 = new Thread(AS_listen_WS,systemName+CommonString.ThreadName+1);
        t1.start();
        
        AStriggerAC AS_trigger_AC = new AStriggerAC(systemName,NetConfig.AdminCenterIP,NetConfig.AdmCen_Listen_AlaSys_Port,_operationAS,_trigger);
        Thread t2 = new Thread(AS_trigger_AC,systemName+CommonString.ThreadName+2 );
        t2.start();

        SlaveObeyBoss Obey_AC = new SlaveObeyBoss(systemName, NetConfig.AdmCen_Control_AlaSys_Port, _operationAS);
        Thread t3 = new Thread(Obey_AC, systemName + CommonString.ThreadName + 3);
        t3.start();

        for (;;) {// test control he thong
            System.out.println(">>>>>>>>>>>>>>>>>" + systemName + (_operationAS.getFlag() ? " ON " : " OFF "));
            try {
                Thread.sleep(3000);
            } catch (InterruptedException ex) {
                Logger.getLogger(AlarmSystemMain.class.getName()).log(Level.SEVERE, null, ex);
            }


        }
    }
}
